<template>
  <el-form ref="loginForm"
           :rules="loginRules"
           :model="loginForm"
           class="login-form"
           status-icon
           label-width="0">
    <el-form-item prop="username">
      <el-input
          v-model="loginForm.username"
          size="small"
          auto-complete="off"
          prefix-icon="el-icon-user-solid"
          placeholder="请输入用户名"
      >
      </el-input>
    </el-form-item>

    <el-form-item prop="password">
      <el-input
          :type="passwordType"
          v-model="loginForm.password"
          size="small"
          auto-complete="off"
          prefix-icon="el-icon-lock"
          placeholder="请输入密码"
      >
        <template #suffix>
          <i class="el-icon-view el-input__icon" @click="showPassword" />
        </template>
      </el-input>
    </el-form-item>

    <el-form-item>
      <el-button size="small" class="login-submit" @click="handleLogin">登录</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  name: "UserLogin",
  components: {},
  data() {
    return {
      passwordType: "password",
      loginForm: {
        username: "admin",
        password: "123456"
      },
      loginRules: {
        username: [
          { required: true, message: "请输入用户名", trigger: "blur" },
        ],
        password: [
          { required: true, message: "请输入密码", trigger: "blur" },
          { min: 6, message: "密码长度最少为6位", trigger: "blur" },
        ],
      }
    };
  },
  computed: {},
  methods: {
    // 显示密码
    showPassword() {
      this.passwordType === ""
          ? (this.passwordType = "password")
          : (this.passwordType = "");
    },
    // 登录
    handleLogin() {
      // this.$refs.loginForm.validate((valid) => {
      //   if (valid) {
      //     this.$refs.verify.show();
      //   }
      // });
      this.$message.success("登录个屁")
    },
  },
};
</script>

<style>
</style>
